<?php
/** @see ZendAuthAdapterAlfresco */
require_once 'ZendAuthAdapterAlfresco.php';

/**
 * Adaptador do ZendAuthAdapterAlfresco para o SPU
 *
 * @author Bruno Cavalcante <brunofcavalcante@gmail.com>
 * @package SPU
 */
class AuthAdapter extends ZendAuthAdapterAlfresco
{
    protected function getIdentityFromResponse()
    {
        $ticket = $this->getTicket();
        $service = new Alfresco_Rest_People($this->_getAlfrescoBaseUrl(), $ticket);
        $person = $service->getPerson($this->getUsername());

        $identity = array();
        $identity['user'] = $person;
        $identity['ticket'] = $ticket;
        $identity['sessionid'] = $this->getSessionIdFromResponse();

        return $identity;
    }

    /**
     * Retorna a URL do Alfresco
     *
     * @return string
     * @see ZendAuthAdapterAlfresco::_getAlfrescoBaseUrl()
     */
    protected function _getAlfrescoBaseUrl()
    {
        return Zend_Registry::get('urlalfresco') . '/service';
    }
}